<?php

namespace app\index\controller;

use app\data\model\ActActivity;
use app\data\model\ActArticleModel;

class ListPage extends BaseController

{
    public function index()
    {
        $this->page = input('page', 1);
        $this->num = input('num', 10);
        $search_title = input('keywords');
        $title_where = $search_title ? [['title', 'like', "%{$search_title}%"]] : [];

        //todo 不能包含不让搜到的文章
        // $query = ActArticleModel::where('cat_id', 3)->where($title_where);
        $query = ActActivity::where('un_public',0)->where('status',1)->field('id,name,begin_time,end_time,abstract,logo');
        
        $this->total = $query->count();

        $this->list = $query->page($this->page, $this->num)->order('id desc')->select();

        $this->fetch('list');
    }
}